POV-Ray : Newsgroups : povray.advanced-users : distinguishing types in scene language : Re: distinguishing types in scene language Server Time
3 May 2024 00:07:50 EDT (-0400)
  Re: distinguishing types in scene language  
From: Jan Walzer
Date: 29 Sep 2000 03:40:02
Message: <39d44752@news.povray.org>
> >   I don't even think that making a set of functions returing a bool
value
> > for this would be hard. For example:
> ...snip...
> >   For exampe isvector() would return true if the parameter is a vector,
> > else false.
>
> I have no idea how to code that, but it should be quite possible.
> However, I think the first thing that would happen is that someone would
> write a macro to put all those functions into one which returns a
> different number or character for each type. Just one function should
> work fine...
> type_of(IDENTIFIER)
> returns:
>     1-float
>     2-2D vector
>     3-3D vector
>     4-color
> etc...
>
> Then variables for each type could be put in a standard include...
> // types.inc
>
> #declare FLOAT = 1;
> #declare VECTOR_2D = 2;
> #declare VECTOR_3D = 3;
> #declare COLOR = 4;
>
> so you could just use this:
>
> #if(type_of(MyIdentifier) = COLOR)
>
> instead of:
>
> #if(is_color(MyIdentifier))
>
> Not only would it take less keywords, but it would be more flexible and
> nearly as easy to use.(easier in some situations)

Does it make sense for CODING, to distinguish between COLOR and
3/4/5-D -Vector ???
I often address my Color-Items in the Vector (r,g,b) with x,y and z ...
Aren't RGB-Color Vectors handled the same way like XYZ-Vectors are ???

So I think it would be better to have one function  for giving back the type
as
    - Vector
    - Integer  (Is there a difference between Float and Integer in POV ???)
    - Float
    - String

And another Function giving the Size of a Vector ... (for XYZ I get 3 and
for RGBFT I get 5)

I think for the correct use of them you have to take care yourself, i.e.
dont mischange RGBFT and RGBTF ...

But (maybe for Effects) there is the possibility in POV to assign a RGBFT to
a RGBTF or a RGB to a XYZ .... So where should the function know from what
it is ??? Maybe it gives you back the type from the time when you last used
it, ... or when you declared it, but this would need to give the type when
declaring them ...

--
Jan Walzer ...


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.